


////////////////////////////////////////////////////////////////////////////////////////////////
/* please refer to Appendix A2 for definitions and sources of all variables in the paper */
////////////////////////////////////////////////////////////////////////////////////////////////

/* load the loan-level data file */
*set appropriate directory
use "county_year.dta", clear



***************************************
/* GEN DESCRIPTIVE STATS IN TABLE 1*/
***************************************

*descriptive stats
outreg2 using county_leveldescriptive.xls  , replace sum(detail) keep(ln_pop county_uemployrate ln_income HHI_originatedloan ln_houseprice foreclosesum_county) eqkeep (N mean sd p25 p50 p75)


*below and above MW presence's median based on the county_year sample  
outreg2 using county_leveldescriptive2.xls if MW_presence>=   .000865 , replace sum(detail) keep(ln_pop county_uemployrate ln_income HHI_originatedloan ln_houseprice foreclosesum_county) eqkeep (N mean sd p25 p50 p75)
outreg2 using county_leveldescriptive1.xls if MW_presence<   .000865 , replace sum(detail) keep(ln_pop county_uemployrate ln_income HHI_originatedloan ln_houseprice foreclosesum_county) eqkeep (N mean sd p25 p50 p75)


***************************************
/* GEN REGRESSION RESULTS IN TABLE 9*/
***************************************

*set control variables 
macro drop _all 
global control_model1   ln_population county_uemployrate ln_income   HHI_originatedloan    
global control_model2   ln_population county_uemployrate ln_income   HHI_originatedloan  change_county_per_cap_income change_county_population  change_county_uemployrate changeHHI


reghdfe  ln_countyoriginatedloan c.MW_presence##i.post_2003       , absorb  ( countyFIPS year ) vce(cluster  countyFIPS)  keepsingletons /*Column 1 */
reghdfe  ln_countyoriginatedloan c.MW_presence##i.post_2003 $control_model1      , absorb  ( countyFIPS year) vce(cluster  countyFIPS)  keepsingletons /*Column 2 */
reghdfe  ln_countyoriginatedloan c.MW_presence##i.post_2003 $control_model2       , absorb  ( countyFIPS year) vce(cluster  countyFIPS)  keepsingletons /*Column 3 */




**********************************************
/* GEN REGRESSION RESULTS IN APPENIX A3*/
**********************************************

xi: reg  MW_presence_in2003 ln_population i.stateFIPS if year ==2000, vce(cluster stateFIPS) /*Column 1 */
xi: reg  MW_presence_in2003 county_uemployrate i.stateFIPS if year ==2000, vce(cluster stateFIPS) /*Column 2 */
xi: reg  MW_presence_in2003 ln_income i.stateFIPS if year ==2000, vce(cluster stateFIPS) /*Column 3 */
xi: reg  MW_presence_in2003 HHI_originatedloan i.stateFIPS if year ==2000,vce(cluster stateFIPS) /*Column 4 */
xi: reg  MW_presence_in2003 ln_houseprice i.stateFIPS if year ==2000, vce(cluster stateFIPS) /*Column 5 */
xi: reg  MW_presence_in2003 foreclosesum_county i.stateFIPS if year ==2000,vce(cluster stateFIPS) /*Column 6 */
xi: reg  MW_presence_in2003 county_frac_soldmortgages i.stateFIPS if year ==2000 , vce(cluster stateFIPS) /*Column 7 */
xi: reg  MW_presence_in2003 ln_countyappreceived i.stateFIPS if year ==2000, vce(cluster stateFIPS) /*Column 8 */
xi: reg  MW_presence_in2003 county_frac_female i.stateFIPS if year ==2000, vce(cluster stateFIPS) /*Column 9 */
xi: reg  MW_presence_in2003 county_frac_minor i.stateFIPS if year ==2000, vce(cluster stateFIPS) /*Column 10 */
xi: reg  MW_presence_in2003 county_frac_samesex i.stateFIPS if year ==2000, vce(cluster stateFIPS) /*Column 11 */





xi: reg  MW_presence_in2003 change_county_population i.stateFIPS if year ==2000, vce(cluster stateFIPS) /*Column 12 */
xi: reg  MW_presence_in2003 change_county_uemployrate i.stateFIPS if year ==2000, vce(cluster stateFIPS) /*Column 13 */
xi: reg  MW_presence_in2003 change_county_per_cap_income i.stateFIPS if year ==2000, vce(cluster stateFIPS) /*Column 14 */
xi: reg  MW_presence_in2003 changeHHI i.stateFIPS if year ==2000, vce(cluster stateFIPS) /*Column 15 */
xi: reg  MW_presence_in2003 houseprice_growth i.stateFIPS if year ==2000, vce(cluster stateFIPS) /*Column 16 */
xi: reg  MW_presence_in2003 changeclosure i.stateFIPS if year ==2000, vce(cluster stateFIPS) /*Column 17 */
xi: reg  MW_presence_in2003 frac_soldmortgages_grow  i.stateFIPS if year ==2000, vce(cluster stateFIPS) /*Column 18 */
xi: reg  MW_presence_in2003 changelnapp i.stateFIPS if year ==2000, vce(cluster stateFIPS) /*Column 19 */
xi: reg  MW_presence_in2003 changefemale i.stateFIPS if year ==2000, vce(cluster stateFIPS) /*Column 20 */
xi: reg  MW_presence_in2003 changeminor i.stateFIPS if year ==2000, vce(cluster stateFIPS) /*Column 21 */
xi: reg  MW_presence_in2003 changesamesex i.stateFIPS if year ==2000, vce(cluster stateFIPS) /*Column 22 */




